<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
                      "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
    <meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
    <title>Zend_CodeGenerator Reference - Zend Framework Manual</title>

    <link href="../css/shCore.css" rel="stylesheet" type="text/css" />
    <link href="../css/shThemeDefault.css" rel="stylesheet" type="text/css" />
    <link href="../css/styles.css" media="all" rel="stylesheet" type="text/css" />
</head>
<body>
<h1>Zend Framework</h1>
<h2>Programmer's Reference Guide</h2>
<ul>
    <li><a href="../en/zend.codegenerator.reference.html">Inglês (English)</a></li>
    <li><a href="../pt-br/zend.codegenerator.reference.html">Português Brasileiro (Brazilian Portuguese)</a></li>
</ul>
<table width="100%">
    <tr valign="top">
        <td width="85%">
            <table width="100%">
                <tr>
                    <td width="25%" style="text-align: left;">
                    <a href="zend.codegenerator.examples.html">Zend_CodeGenerator Examples</a>
                    </td>

                    <td width="50%" style="text-align: center;">
                        <div class="up"><span class="up"><a href="zend.codegenerator.html">Zend_CodeGenerator</a></span><br />
                        <span class="home"><a href="manual.html">Programmer's Reference Guide</a></span></div>
                    </td>

                    <td width="25%" style="text-align: right;">
                        <div class="next" style="text-align: right; float: right;"><a href="zend.config.html">Zend_Config</a></div>
                    </td>
                </tr>
            </table>
<hr />
<div id="zend.codegenerator.reference" class="section"><div class="info"><h1 class="title">Zend_CodeGenerator Reference</h1></div>
    

    <div class="section" id="zend.codegenerator.reference.abstracts"><div class="info"><h1 class="title">Abstract Classes and Interfaces</h1></div>
        

        <div class="section" id="zend.codegenerator.reference.abstracts.abstract"><div class="info"><h1 class="title">Zend_CodeGenerator_Abstract</h1></div>
            

            <p class="para">
                The base class from which all CodeGenerator classes inherit
                provides the minimal functionality necessary. It&#039;s <acronym class="acronym">API</acronym> is as
                follows:
            </p>

            <pre class="programlisting brush: php">
abstract class Zend_CodeGenerator_Abstract
{
    final public function __construct(Array $options = array())
    public function setOptions(Array $options)
    public function setSourceContent($sourceContent)
    public function getSourceContent()
    protected function _init()
    protected function _prepare()
    abstract public function generate();
    final public function __toString()
}
</pre>


            <p class="para">
                The constructor first calls  <span class="methodname">_init()</span> (which is left
                empty for the concrete extending class to implement), then
                passes the <var class="varname">$options</var> parameter to
                 <span class="methodname">setOptions()</span>, and finally calls
                 <span class="methodname">_prepare()</span> (again, to be implemented by an
                extending class).
            </p>

            <p class="para">
                Like most classes in Zend Framework,  <span class="methodname">setOptions()</span>
                compares an option key to existing setters in the class, and
                passes the value on to that method if found.
            </p>

            <p class="para">
                 <span class="methodname">__toString()</span> is marked as final, and proxies to
                 <span class="methodname">generate()</span>.
            </p>

            <p class="para">
                 <span class="methodname">setSourceContent()</span> and
                 <span class="methodname">getSourceContent()</span> are intended to either set the
                default content for the code being generated, or to replace said
                content once all generation tasks are complete.
            </p>
        </div>

        <div class="section" id="zend.codegenerator.reference.abstracts.php-abstract"><div class="info"><h1 class="title">Zend_CodeGenerator_Php_Abstract</h1></div>
            

            <p class="para">
                <span class="classname">Zend_CodeGenerator_Php_Abstract</span> extends
                <span class="classname">Zend_CodeGenerator_Abstract</span>, and adds some
                properties for tracking whether content has changed as well as
                the amount of indentation that should appear before generated
                content. Its <acronym class="acronym">API</acronym> is as follows:
            </p>

            <pre class="programlisting brush: php">
abstract class Zend_CodeGenerator_Php_Abstract
    extends Zend_CodeGenerator_Abstract
{
    public function setSourceDirty($isSourceDirty = true)
    public function isSourceDirty()
    public function setIndentation($indentation)
    public function getIndentation()
}
</pre>

        </div>

        <div class="section" id="zend.codegenerator.reference.abstracts.php-member-abstract"><div class="info"><h1 class="title">Zend_CodeGenerator_Php_Member_Abstract</h1></div>
            

            <p class="para">
                <span class="classname">Zend_CodeGenerator_Php_Member_Abstract</span> is a base
                class for generating class members -- properties and methods --
                and provides accessors and mutators for establishing visibility;
                whether or not the member is abstract, static, or final; and the
                name of the member. Its <acronym class="acronym">API</acronym> is as follows:
            </p>

            <pre class="programlisting brush: php">
abstract class Zend_CodeGenerator_Php_Member_Abstract
    extends Zend_CodeGenerator_Php_Abstract
{
    public function setAbstract($isAbstract)
    public function isAbstract()
    public function setStatic($isStatic)
    public function isStatic()
    public function setVisibility($visibility)
    public function getVisibility()
    public function setName($name)
    public function getName()
}
</pre>

        </div>
    </div>

    <div class="section" id="zend.codegenerator.reference.concrete"><div class="info"><h1 class="title">Concrete CodeGenerator Classes</h1></div>
        

        <div class="section" id="zend.codegenerator.reference.concrete.php-body"><div class="info"><h1 class="title">Zend_CodeGenerator_Php_Body</h1></div>
            

            <p class="para">
                <span class="classname">Zend_CodeGenerator_Php_Body</span> is intended for
                generating arbitrary procedural code to include within a file.
                As such, you simply set content for the object, and it will
                return that content when you invoke  <span class="methodname">generate()</span>.
            </p>

            <p class="para">
                The <acronym class="acronym">API</acronym> of the class is as follows:
            </p>

            <pre class="programlisting brush: php">
class Zend_CodeGenerator_Php_Body extends Zend_CodeGenerator_Php_Abstract
{
    public function setContent($content)
    public function getContent()
    public function generate()
}
</pre>

        </div>

        <div class="section" id="zend.codegenerator.reference.concrete.php-class"><div class="info"><h1 class="title">Zend_CodeGenerator_Php_Class</h1></div>
            

            <p class="para">
                <span class="classname">Zend_CodeGenerator_Php_Class</span> is intended for
                generating <acronym class="acronym">PHP</acronym> classes. The basic functionality just generates
                the <acronym class="acronym">PHP</acronym> class itself, as well as optionally the related
                <acronym class="acronym">PHP</acronym> DocBlock. Classes may implement or inherit from other
                classes, and may be marked as abstract. Utilizing other code generator
                classes, you can also attach class constants, properties, and
                methods.
            </p>

            <p class="para">
                The <acronym class="acronym">API</acronym> is as follows:
            </p>

            <pre class="programlisting brush: php">
class Zend_CodeGenerator_Php_Class extends Zend_CodeGenerator_Php_Abstract
{
    public static function fromReflection(
        Zend_Reflection_Class $reflectionClass
    )
    public function setDocblock(Zend_CodeGenerator_Php_Docblock $docblock)
    public function getDocblock()
    public function setName($name)
    public function getName()
    public function setAbstract($isAbstract)
    public function isAbstract()
    public function setExtendedClass($extendedClass)
    public function getExtendedClass()
    public function setImplementedInterfaces(Array $implementedInterfaces)
    public function getImplementedInterfaces()
    public function setProperties(Array $properties)
    public function setProperty($property)
    public function getProperties()
    public function getProperty($propertyName)
    public function setMethods(Array $methods)
    public function setMethod($method)
    public function getMethods()
    public function getMethod($methodName)
    public function hasMethod($methodName)
    public function isSourceDirty()
    public function generate()
}
</pre>


            <p class="para">
                The  <span class="methodname">setProperty()</span> method accepts an array of
                information that may be used to generate a
                <span class="classname">Zend_CodeGenerator_Php_Property</span> instance -- or
                simply an instance of
                <span class="classname">Zend_CodeGenerator_Php_Property</span>.
                Likewise,  <span class="methodname">setMethod()</span> accepts either an array of
                information for generating a
                <span class="classname">Zend_CodeGenerator_Php_Method</span> instance or a
                concrete instance of that class.
            </p>

            <p class="para">
                Note that  <span class="methodname">setDocBlock()</span> expects an instance of
                <span class="classname">Zend_CodeGenerator_Php_DocBlock</span>.
            </p>
        </div>

        <div class="section" id="zend.codegenerator.reference.concrete.php-docblock"><div class="info"><h1 class="title">Zend_CodeGenerator_Php_Docblock</h1></div>
            

            <p class="para">
                <span class="classname">Zend_CodeGenerator_Php_Docblock</span> can be used to
                generate arbitrary <acronym class="acronym">PHP</acronym> docblocks, including all the standard
                docblock features: short and long descriptions and annotation
                tags.
            </p>

            <p class="para">
                Annotation tags may be set using the  <span class="methodname">setTag()</span> and
                 <span class="methodname">setTags()</span> methods; these each take either an array
                describing the tag that may be passed to the
                <span class="classname">Zend_CodeGenerator_Php_Docblock_Tag</span> constructor, or
                an instance of that class.
            </p>

            <p class="para">
                The <acronym class="acronym">API</acronym> is as follows:
            </p>

            <pre class="programlisting brush: php">
class Zend_CodeGenerator_Php_Docblock extends Zend_CodeGenerator_Php_Abstract
{
    public static function fromReflection(
        Zend_Reflection_Docblock $reflectionDocblock
    )
    public function setShortDescription($shortDescription)
    public function getShortDescription()
    public function setLongDescription($longDescription)
    public function getLongDescription()
    public function setTags(Array $tags)
    public function setTag($tag)
    public function getTags()
    public function generate()
}
</pre>

        </div>

        <div class="section" id="zend.codegenerator.reference.concrete.php-docblock-tag"><div class="info"><h1 class="title">Zend_CodeGenerator_Php_Docblock_Tag</h1></div>
            

            <p class="para">
                <span class="classname">Zend_CodeGenerator_Php_Docblock_Tag</span> is intended for
                creating arbitrary annotation tags for inclusion in <acronym class="acronym">PHP</acronym>
                docblocks. Tags are expected to contain a name (the portion
                immediately following the &#039;@&#039; symbol) and a description
                (everything following the tag name).
            </p>

            <p class="para">
                The class <acronym class="acronym">API</acronym> is as follows:
            </p>

            <pre class="programlisting brush: php">
class Zend_CodeGenerator_Php_Docblock_Tag
    extends Zend_CodeGenerator_Php_Abstract
{
    public static function fromReflection(
        Zend_Reflection_Docblock_Tag $reflectionTag
    )
    public function setName($name)
    public function getName()
    public function setDescription($description)
    public function getDescription()
    public function generate()
}
</pre>

        </div>

        <div class="section" id="zend.codegenerator.reference.concrete.php-docblock-tag-param"><div class="info"><h1 class="title">Zend_CodeGenerator_Php_DocBlock_Tag_Param</h1></div>
            

            <p class="para">
                <span class="classname">Zend_CodeGenerator_Php_DocBlock_Tag_Param</span> is a
                specialized version of
                <span class="classname">Zend_CodeGenerator_Php_DocBlock_Tag</span>, and represents
                a method parameter. The tag name is therefor known (&quot;param&quot;),
                but due to the format of this annotation tag, additional
                information is required in order to generate it: the parameter
                name and data type it represents.
            </p>

            <p class="para">
                The class <acronym class="acronym">API</acronym> is as follows:
            </p>

            <pre class="programlisting brush: php">
class Zend_CodeGenerator_Php_Docblock_Tag_Param
    extends Zend_CodeGenerator_Php_Docblock_Tag
{
    public static function fromReflection(
        Zend_Reflection_Docblock_Tag $reflectionTagParam
    )
    public function setDatatype($datatype)
    public function getDatatype()
    public function setParamName($paramName)
    public function getParamName()
    public function generate()
}
</pre>

        </div>

        <div class="section" id="zend.codegenerator.reference.concrete.php-docblock-tag-return"><div class="info"><h1 class="title">Zend_CodeGenerator_Php_DocBlock_Tag_Return</h1></div>
            

            <p class="para">
                Like the param docblock tag variant,
                <span class="classname">Zend_CodeGenerator_Php_Docblock_Tab_Return</span> is an
                annotation tag variant for representing a method return value.
                In this case, the annotation tag name is known (&quot;return&quot;), but
                requires a return type.
            </p>

            <p class="para">
                The class <acronym class="acronym">API</acronym> is as follows:
            </p>

            <pre class="programlisting brush: php">
class Zend_CodeGenerator_Php_Docblock_Tag_Param
    extends Zend_CodeGenerator_Php_Docblock_Tag
{
    public static function fromReflection(
        Zend_Reflection_Docblock_Tag $reflectionTagReturn
    )
    public function setDatatype($datatype)
    public function getDatatype()
    public function generate()
}
</pre>

        </div>

        <div class="section" id="zend.codegenerator.reference.concrete.php-file"><div class="info"><h1 class="title">Zend_CodeGenerator_Php_File</h1></div>
            

            <p class="para">
                <span class="classname">Zend_CodeGenerator_Php_File</span> is used to generate
                the full contents of a file that will contain <acronym class="acronym">PHP</acronym> code. The file
                may contain classes or arbitrary <acronym class="acronym">PHP</acronym> code, as well as a
                file-level docblock if desired.
            </p>

            <p class="para">
                When adding classes to the file, you will need to pass either an
                array of information to pass to the
                <span class="classname">Zend_CodeGenerator_Php_Class</span> constructor, or an
                instance of that class. Similarly, with docblocks, you will need
                to pass information for the
                <span class="classname">Zend_CodeGenerator_Php_Docblock</span> constructor to
                consume or an instance of the class.
            </p>

            <p class="para">
                The <acronym class="acronym">API</acronym> of the class is as follows:
            </p>

            <pre class="programlisting brush: php">
class Zend_CodeGenerator_Php_File extends Zend_CodeGenerator_Php_Abstract
{
    public static function fromReflectedFilePath(
        $filePath,
        $usePreviousCodeGeneratorIfItExists = true,
        $includeIfNotAlreadyIncluded = true)
    public static function fromReflection(Zend_Reflection_File $reflectionFile)
    public function setDocblock(Zend_CodeGenerator_Php_Docblock $docblock)
    public function getDocblock()
    public function setRequiredFiles($requiredFiles)
    public function getRequiredFiles()
    public function setClasses(Array $classes)
    public function getClass($name = null)
    public function setClass($class)
    public function setFilename($filename)
    public function getFilename()
    public function getClasses()
    public function setBody($body)
    public function getBody()
    public function isSourceDirty()
    public function generate()
}
</pre>

        </div>

        <div class="section" id="zend.codegenerator.reference.concrete.php-member-container"><div class="info"><h1 class="title">Zend_CodeGenerator_Php_Member_Container</h1></div>
            

            <p class="para">
                <span class="classname">Zend_CodeGenerator_Php_Member_Container</span> is used
                internally by <span class="classname">Zend_CodeGenerator_Php_Class</span> to keep
                track of class members -- properties and methods alike. These
                are indexed by name, using the concrete instances of the members
                as values.
            </p>

            <p class="para">
                The <acronym class="acronym">API</acronym> of the class is as follows:
            </p>

            <pre class="programlisting brush: php">
class Zend_CodeGenerator_Php_Member_Container extends ArrayObject
{
    public function __construct($type = self::TYPE_PROPERTY)
}
</pre>

        </div>

        <div class="section" id="zend.codegenerator.reference.concrete.php-method"><div class="info"><h1 class="title">Zend_CodeGenerator_Php_Method</h1></div>
            

            <p class="para">
                <span class="classname">Zend_CodeGenerator_Php_Method</span> describes a class
                method, and can generate both the code and the docblock for the
                method. The visibility and status as static,
                abstract, or final may be indicated, per its parent class,
                <span class="classname">Zend_CodeGenerator_Php_Member_Abstract</span>. Finally,
                the parameters and return value for the method may be specified.
            </p>

            <p class="para">
                Parameters may be set using  <span class="methodname">setParameter()</span> or
                 <span class="methodname">setParameters()</span>. In each case, a parameter should
                either be an array of information to pass to the
                <span class="classname">Zend_CodeGenerator_Php_Parameter</span> constructor or an
                instance of that class.
            </p>

            <p class="para">
                The <acronym class="acronym">API</acronym> of the class is as follows:
            </p>

            <pre class="programlisting brush: php">
class Zend_CodeGenerator_Php_Method
    extends Zend_CodeGenerator_Php_Member_Abstract
{
    public static function fromReflection(
        Zend_Reflection_Method $reflectionMethod
    )
    public function setDocblock(Zend_CodeGenerator_Php_Docblock $docblock)
    public function getDocblock()
    public function setFinal($isFinal)
    public function setParameters(Array $parameters)
    public function setParameter($parameter)
    public function getParameters()
    public function setBody($body)
    public function getBody()
    public function generate()
}
</pre>

        </div>

        <div class="section" id="zend.codegenerator.reference.concrete.php-parameter"><div class="info"><h1 class="title">Zend_CodeGenerator_Php_Parameter</h1></div>
            

            <p class="para">
                <span class="classname">Zend_CodeGenerator_Php_Parameter</span> may be used to
                specify method parameters. Each parameter may have a position
                (if unspecified, the order in which they are registered with the
                method will be used), a default value, and a data type; a
                parameter name is required.
            </p>

            <p class="para">
                The <acronym class="acronym">API</acronym> of the class is as follows:
            </p>

            <pre class="programlisting brush: php">
class Zend_CodeGenerator_Php_Parameter extends Zend_CodeGenerator_Php_Abstract
{
    public static function fromReflection(
        Zend_Reflection_Parameter $reflectionParameter
    )
    public function setType($type)
    public function getType()
    public function setName($name)
    public function getName()
    public function setDefaultValue($defaultValue)
    public function getDefaultValue()
    public function setPosition($position)
    public function getPosition()
    public function getPassedByReference()
    public function setPassedByReference($passedByReference)
    public function generate()
}
</pre>


            <p class="para">
                There are several problems that might occur when trying to set
                <b><tt>NULL</tt></b>, booleans or arrays as default values. For this the value
                holder object <span class="classname">Zend_CodeGenerator_Php_ParameterDefaultValue</span>
                can be used, for example:
            </p>

            <pre class="programlisting brush: php">
$parameter = new Zend_CodeGenerator_Php_Parameter();
$parameter-&gt;setDefaultValue(
    new Zend_CodeGenerator_Php_Parameter_DefaultValue(&quot;null&quot;)
);
$parameter-&gt;setDefaultValue(
    new Zend_CodeGenerator_Php_Parameter_DefaultValue(&quot;array(&#039;foo&#039;, &#039;bar&#039;)&quot;)
);
</pre>


            <p class="para">
                Internally  <span class="methodname">setDefaultValue()</span> also converts the values
                which can&#039;t be expressed in <acronym class="acronym">PHP</acronym> into the value holder.
            </p>
        </div>

        <div class="section" id="zend.codegenerator.reference.concrete.php-property"><div class="info"><h1 class="title">Zend_CodeGenerator_Php_Property</h1></div>
            

            <p class="para">
                <span class="classname">Zend_CodeGenerator_Php_Property</span> describes a class
                property, which may be either a constant or a variable. In each
                case, the property may have an optional default value associated
                with it. Additionally, the visibility of variable properties may
                be set, per the parent class,
                <span class="classname">Zend_CodeGenerator_Php_Member_Abstract</span>.
            </p>

            <p class="para">
                The <acronym class="acronym">API</acronym> of the class is as follows:
            </p>

            <pre class="programlisting brush: php">
class Zend_CodeGenerator_Php_Property
    extends Zend_CodeGenerator_Php_Member_Abstract
{
    public static function fromReflection(
        Zend_Reflection_Property $reflectionProperty
    )
    public function setConst($const)
    public function isConst()
    public function setDefaultValue($defaultValue)
    public function getDefaultValue()
    public function generate()
}
</pre>

        </div>
    </div>
</div>
        <hr />

            <table width="100%">
                <tr>
                    <td width="25%" style="text-align: left;">
                    <a href="zend.codegenerator.examples.html">Zend_CodeGenerator Examples</a>
                    </td>

                    <td width="50%" style="text-align: center;">
                        <div class="up"><span class="up"><a href="zend.codegenerator.html">Zend_CodeGenerator</a></span><br />
                        <span class="home"><a href="manual.html">Programmer's Reference Guide</a></span></div>
                    </td>

                    <td width="25%" style="text-align: right;">
                        <div class="next" style="text-align: right; float: right;"><a href="zend.config.html">Zend_Config</a></div>
                    </td>
                </tr>
            </table>
</td>
        <td style="font-size: smaller;" width="15%"> <style type="text/css">
#leftbar {
	float: left;
	width: 186px;
	padding: 5px;
	font-size: smaller;
}
ul.toc {
	margin: 0px 5px 5px 5px;
	padding: 0px;
}
ul.toc li {
	font-size: 85%;
	margin: 1px 0 1px 1px;
	padding: 1px 0 1px 11px;
	list-style-type: none;
	background-repeat: no-repeat;
	background-position: center left;
}
ul.toc li.header {
	font-size: 115%;
	padding: 5px 0px 5px 11px;
	border-bottom: 1px solid #cccccc;
	margin-bottom: 5px;
}
ul.toc li.active {
	font-weight: bold;
}
ul.toc li a {
	text-decoration: none;
}
ul.toc li a:hover {
	text-decoration: underline;
}
</style>
 <ul class="toc">
  <li class="header home"><a href="manual.html">Programmer's Reference Guide</a></li>
  <li class="header up"><a href="manual.html">Programmer's Reference Guide</a></li>
  <li class="header up"><a href="reference.html">Zend Framework Reference</a></li>
  <li class="header up"><a href="zend.codegenerator.html">Zend_CodeGenerator</a></li>
  <li><a href="zend.codegenerator.introduction.html">Introduction</a></li>
  <li><a href="zend.codegenerator.examples.html">Zend_CodeGenerator Examples</a></li>
  <li class="active"><a href="zend.codegenerator.reference.html">Zend_CodeGenerator Reference</a></li>
 </ul>
 </td>
    </tr>
</table>

<script type="text/javascript" src="../js/shCore.js"></script>
<script type="text/javascript" src="../js/shAutoloader.js"></script>
<script type="text/javascript" src="../js/main.js"></script>

</body>
</html>